package com.jucai.pppeiyouclient.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by Kuky on 2017-02-13.
 */
public class QuickFragmentAdapter<T extends Fragment> extends FragmentPagerAdapter {
    protected List<T> mList;
    protected String[] titles;

    public void setData(List<T> data) {
        this.mList = data;
        notifyDataSetChanged();
    }

    public QuickFragmentAdapter(FragmentManager fm, List<T> list, String[] titles) {
        super(fm);
        this.mList = list;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mList.get(position);
    }

    @Override
    public int getCount() {
        return mList.size();
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titles == null ? super.getPageTitle(position) : titles[position];
    }
}
